/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package gamedsl2.impl;

import gamedsl2.ActorPhysics;
import gamedsl2.Gamedsl2Package;
import gamedsl2.State;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Actor Physics</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link gamedsl2.impl.ActorPhysicsImpl#getSize <em>Size</em>}</li>
 *   <li>{@link gamedsl2.impl.ActorPhysicsImpl#getGameState <em>Game State</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class ActorPhysicsImpl extends AbstractEntityImpl implements ActorPhysics {
	/**
	 * The default value of the '{@link #getSize() <em>Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSize()
	 * @generated
	 * @ordered
	 */
	protected static final float SIZE_EDEFAULT = 0.0F;

	/**
	 * The cached value of the '{@link #getSize() <em>Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSize()
	 * @generated
	 * @ordered
	 */
	protected float size = SIZE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getGameState() <em>Game State</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGameState()
	 * @generated
	 * @ordered
	 */
	protected State gameState;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActorPhysicsImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Gamedsl2Package.Literals.ACTOR_PHYSICS;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public float getSize() {
		return size;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSize(float newSize) {
		float oldSize = size;
		size = newSize;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Gamedsl2Package.ACTOR_PHYSICS__SIZE, oldSize, size));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public State getGameState() {
		if (gameState != null && gameState.eIsProxy()) {
			InternalEObject oldGameState = (InternalEObject)gameState;
			gameState = (State)eResolveProxy(oldGameState);
			if (gameState != oldGameState) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, Gamedsl2Package.ACTOR_PHYSICS__GAME_STATE, oldGameState, gameState));
			}
		}
		return gameState;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public State basicGetGameState() {
		return gameState;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetGameState(State newGameState, NotificationChain msgs) {
		State oldGameState = gameState;
		gameState = newGameState;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Gamedsl2Package.ACTOR_PHYSICS__GAME_STATE, oldGameState, newGameState);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGameState(State newGameState) {
		if (newGameState != gameState) {
			NotificationChain msgs = null;
			if (gameState != null)
				msgs = ((InternalEObject)gameState).eInverseRemove(this, Gamedsl2Package.STATE__PLAYER, State.class, msgs);
			if (newGameState != null)
				msgs = ((InternalEObject)newGameState).eInverseAdd(this, Gamedsl2Package.STATE__PLAYER, State.class, msgs);
			msgs = basicSetGameState(newGameState, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Gamedsl2Package.ACTOR_PHYSICS__GAME_STATE, newGameState, newGameState));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Gamedsl2Package.ACTOR_PHYSICS__GAME_STATE:
				if (gameState != null)
					msgs = ((InternalEObject)gameState).eInverseRemove(this, Gamedsl2Package.STATE__PLAYER, State.class, msgs);
				return basicSetGameState((State)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Gamedsl2Package.ACTOR_PHYSICS__GAME_STATE:
				return basicSetGameState(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Gamedsl2Package.ACTOR_PHYSICS__SIZE:
				return getSize();
			case Gamedsl2Package.ACTOR_PHYSICS__GAME_STATE:
				if (resolve) return getGameState();
				return basicGetGameState();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Gamedsl2Package.ACTOR_PHYSICS__SIZE:
				setSize((Float)newValue);
				return;
			case Gamedsl2Package.ACTOR_PHYSICS__GAME_STATE:
				setGameState((State)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Gamedsl2Package.ACTOR_PHYSICS__SIZE:
				setSize(SIZE_EDEFAULT);
				return;
			case Gamedsl2Package.ACTOR_PHYSICS__GAME_STATE:
				setGameState((State)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Gamedsl2Package.ACTOR_PHYSICS__SIZE:
				return size != SIZE_EDEFAULT;
			case Gamedsl2Package.ACTOR_PHYSICS__GAME_STATE:
				return gameState != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (size: ");
		result.append(size);
		result.append(')');
		return result.toString();
	}

} //ActorPhysicsImpl
